//
//  4-6.cpp
//  mm
//
//  Created by  AbbyCin on 12/16/14.
//  Copyright (c) 2014  AbbyCin. All rights reserved.
//

#include <iostream>

int main()
{
    using namespace std;
    
    struct candybar {
        char brand[20];
        float mass;
        int calories;
    };
    
    candybar snack[3];
  // in a comlex way
    for(int i=0; i<3; i++)
    {
        cout << "brand: "; cin.getline((snack + i)->brand, 20) ; cout << endl;
        cout << "mass: "; cin >> (snack + i)->mass; cout << endl;
        cout << "calories: "; (cin >> (snack + i)->calories).get(); cout << endl;   // .get() is of paramount importance
    }
    
    for(int i=0; i<3; i++)
    {
        cout << "brand: " << (snack + i)->brand << endl;
        cout << "mass: " << (snack + i)->mass << endl;
        cout << "calories: " << (snack + i)->calories << endl;
    }
    return 0;
}
